home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1993-11-04 | 2.4 KB | 66 lines |
- (******************************************************************************
-
- :Program. Sorting.def
- :Contents. procedure for sorting
- :Author. Markus Uhlendahl
- :Address. Vorm Burgtor 16, D-4408 Dülmen
- :Phone. 02594/81540
- :Language. Modula-2
- :Translator. M2Amiga 4.0d
- :Copyright. Public Domain
- :History. 15.11.91 --- 1.0 --- first release
-
- ******************************************************************************)
- DEFINITION MODULE Sorting;
-
-
- TYPE
- SwapProcedure=PROCEDURE (LONGINT,LONGINT);
- (*
- * FUNCTION swap two elements of an array
- * Swaps two elements of an array.
- * INPUTS LONGINT = index of an element in the array
- * LONGINT = index of an element in the array
- *
- *)
- Comparison=PROCEDURE (LONGINT,LONGINT) : BOOLEAN;
- (*
- * FUNCTION compare two elements
- * Compares two elements of an array.
- * INPUTS LONGINT = index of an element in the array
- * LONGINT = index of an element in the array
- * RESULTS TRUE if the comparison is TRUE else FALSE
- *
- *)
-
-
- PROCEDURE QuickSort (first,last : LONGINT;
- Lower : Comparison;
- Swap : SwapProcedure;
- ascending : BOOLEAN);
- (*
- * FUNCTION sort an array
- * This implementation of the quicksort-algorythm is very
- * flexible. It sorts arrays of every type and the user can
- * choose if the array is sorted ascending or not. To make this
- * possible the user has to write two procedures. One that
- * compares two elements of the array and one that swaps two
- * elements.
- * INPUTS first = first index of the array
- * last = last index of the array
- * Lower = PROCEDURE which compares two elements of the array
- * returns TRUE if the first element of the comparison
- * is really lower (a<b) than the second element
- * Swap = PROCEDURE which swaps two elements of the array
- * ascending = if ascending is TRUE the first element of the
- * array will be the smallest and the last element
- * the greatest
- * if ascending is FALSE it will be vice versa
- * BUGS none known
- * AUTHOR Markus Uhlendahl
- *
- *)
-
-
- END Sorting.
-